import 'package:app_core/app_core.dart';

/// 用户相关API声明（enum+BaseApi）
/// // 在内存中，每个枚举值都是这样的实例：
// UserApi.register = {
//   path: '/user/register',
//   method: HttpMethod.post
// }

// 上下文	语法	关系	含义	示例
// 类继承	class B extends A	继承	B 是 A 的子类	class Dog extends Animal
// 接口实现	class B implements A	实现	B 实现 A 的契约	enum UserApi implements BaseApi
// 泛型约束	<T extends A>	约束	T 必须是 A 或其子类型	<Api extends BaseApi>

enum UserApi implements BaseApi {
  register('/user/register', HttpMethod.post),
  // login('/user/login', HttpMethod.post),
  userInfo('/user/info', HttpMethod.get),
  roomList('/user/room/list', HttpMethod.get),
  modifyRoom('/user/room/modify', HttpMethod.post),
  forgetPwd('/user/forgetPwd', HttpMethod.post),
  sendEmailCode('/user/sendEmailCode', HttpMethod.post),

  ///获取版本号
  commonVersion('/common/version', HttpMethod.post),

  ///发送验证码
  codeSend('/common/verification/email/send', HttpMethod.post),

  ///登录
  login('/common/app/login/code', HttpMethod.post);

  @override
  final String path;
  @override
  final HttpMethod method;
  const UserApi(this.path, this.method);
}

/// 使用示例：
/// final resp = await UserApi.login.request<UserModel>(
///   data: {'email': 'test@example.com', 'password': '123456'},
///   fromJson: UserModel.fromJson,
/// );
/// if (resp.isSuccess) print(resp.data);
/// final res = await UserApi.userList.request<List<UserModel>>(
///   fromJson: UserModel.fromJson,
/// );
/// List<UserModel> users = res.data!;
/// final res = await UserApi.userList.request();
